2. Find contrast characteristics among the correlation coefficients above
2-1-1. Low Pearson (< 0.40) and High Spearman (> 0.60) (linearity vs monotone)
cor_contrast1 <- (abs(cor_pearson_mat) < 0.4) & (abs(cor_spearman_mat) > 0.6)
cor_contrast_ind1 <- which(cor_contrast1, arr.ind = T)
nrow(cor_contrast_ind1)
## [1] 3
2-1-2. Visualization of Low Pearson (< 0.40) and High Spearman (> 0.60) (linearity vs monotone)
par(mfrow = c(2, 2))
for (i in 1:nrow(cor_contrast_ind1)){
index1 <- cor_contrast_ind1[i, 1]; index2 <- cor_contrast_ind1[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("Spearman of ", round(cor_spearman_mat[index1, index2], 3))))
}

2-2-1. High Pearson (> 0.85) and Low Spearman (< 0.15) (linearity vs monotone)
cor_contrast2 <- (abs(cor_pearson_mat) > 0.85) & (abs(cor_spearman_mat) < 0.15)
cor_contrast_ind2 <- which(cor_contrast2, arr.ind = T)
nrow(cor_contrast_ind2)
## [1] 4
2-2-2. Visualization of High Pearson (> 0.85) and Low Spearman (< 0.15) (linearity vs monotone)
par(mfrow = c(2, 2))
for (i in 1:nrow(cor_contrast_ind2)){
index1 <- cor_contrast_ind2[i, 1]; index2 <- cor_contrast_ind2[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("Spearman of ", round(cor_spearman_mat[index1, index2], 3))))
}

2-2-1. Low Pearson (< 0.50) and High Kendall (> 0.50) (linearity vs monotone)
cor_contrast3 <- (abs(cor_pearson_mat) < 0.5) & (abs(cor_kendall_mat) > 0.5)
cor_contrast_ind3 <- which(cor_contrast3, arr.ind = T)
nrow(cor_contrast_ind3)
## [1] 14
2-2-2. Visualization of Low Pearson (< 0.50) and High Kendall (> 0.50) (linearity vs monotone)
par(mfrow = c(2, 5))
for (i in 1:10){
index1 <- cor_contrast_ind3[i, 1]; index2 <- cor_contrast_ind3[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("Kendall of ", round(cor_kendall_mat[index1, index2], 3))))
}

2-4-1. High Pearson (> 0.85) and Low Kendall (< 0.15) (linearity vs monotone)
cor_contrast4 <- (abs(cor_pearson_mat) > 0.85) & (abs(cor_kendall_mat) < 0.15)
cor_contrast_ind4 <- which(cor_contrast4, arr.ind = T)
nrow(cor_contrast_ind4)
## [1] 7
2-4-2. Visualization of High Pearson (> 0.85) and Low Kendall (< 0.15) (linearity vs monotone)
par(mfrow = c(2, 4))
for (i in 1:nrow(cor_contrast_ind4)){
index1 <- cor_contrast_ind4[i, 1]; index2 <- cor_contrast_ind4[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("Kendall of ", round(cor_kendall_mat[index1, index2], 3))))
}

2-5-1. Low Pearson (< 0.50) and High Hoeffding’s D (> 0.50) (linearity vs monotone)
cor_contrast5 <- (abs(cor_pearson_mat) < 0.5) & (abs(cor_hoeffd_mat) > 0.5)
cor_contrast_ind5 <- which(cor_contrast5, arr.ind = T)
nrow(cor_contrast_ind5)
## [1] 0
2-6-1. High Pearson (> 0.90) and Low Hoeffding’s D (< 0.05) (linearity vs monotone)
cor_contrast6 <- (abs(cor_pearson_mat) > 0.9) & (abs(cor_hoeffd_mat) < 0.05)
cor_contrast_ind6 <- which(cor_contrast6, arr.ind = T)
nrow(cor_contrast_ind6)
## [1] 9
2-6-2. Visualization of High Pearson (> 0.90) and Low Hoeffding’s D (< 0.05) (linearity vs monotone)
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind6)){
index1 <- cor_contrast_ind6[i, 1]; index2 <- cor_contrast_ind6[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("Hoeffding's D of ", round(cor_hoeffd_mat[index1, index2], 3))))
}

2-7-1. Low Pearson (< 0.05) and high Blomqvist’s beta (> 0.90) (linearity vs monotone)
cor_contrast7 <- (abs(cor_pearson_mat) < 0.05) & (abs(cor_blomqvist_mat) > 0.9)
cor_contrast_ind7 <- which(cor_contrast7, arr.ind = T)
nrow(cor_contrast_ind7)
## [1] 7
2-7-2. Visualization of Low Pearson (< 0.05) and high Blomqvist’s beta (> 0.90) (linearity vs monotone)
par(mfrow = c(2, 4))
for (i in 1:nrow(cor_contrast_ind7)){
index1 <- cor_contrast_ind7[i, 1]; index2 <- cor_contrast_ind7[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("Beta of ", round(cor_blomqvist_mat[index1, index2], 3))))
}

2-8-1. High Pearson (> 0.90) and Low Blomqvist’s beta (< 0.20) (linearity vs monotone)
cor_contrast8 <- (abs(cor_pearson_mat) > 0.9) & (abs(cor_blomqvist_mat) < 0.2)
cor_contrast_ind8 <- which(cor_contrast8, arr.ind = T)
nrow(cor_contrast_ind8)
## [1] 6
2-8-2. Visualization of High Pearson (> 0.90) and Low Blomqvist’s beta (< 0.20) (linearity vs monotone)
par(mfrow = c(2, 3))
for (i in 1:nrow(cor_contrast_ind8)){
index1 <- cor_contrast_ind8[i, 1]; index2 <- cor_contrast_ind8[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("Beta of ", round(cor_blomqvist_mat[index1, index2], 3))))
}

2-9-1. Low Pearson (< 0.50) and High XI (> 0.50) (linearity vs non-linearity)
cor_contrast9 <- (abs(cor_pearson_mat) < 0.5) & (abs(cor_XI_mat) > 0.5)
cor_contrast_ind9 <- which(cor_contrast9, arr.ind = T)
nrow(cor_contrast_ind9)
## [1] 0
2-10-1. High Pearson (> 0.90) and Low XI (< 0.15) (linearity vs non-linearity)
cor_contrast10 <- (abs(cor_pearson_mat) > 0.9) & (abs(cor_XI_mat) < 0.15)
cor_contrast_ind10 <- which(cor_contrast10, arr.ind = T)
nrow(cor_contrast_ind10)
## [1] 8
2-10-2. Visualization of High Pearson (> 0.90) and Low XI (< 0.15) (linearity vs non-linearity)
par(mfrow = c(2, 4))
for (i in 1:nrow(cor_contrast_ind10)){
index1 <- cor_contrast_ind10[i, 1]; index2 <- cor_contrast_ind10[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("XI of ", round(cor_XI_mat[index1, index2], 3))))
}

2-11-1. Low Spearman (< 0.05) and High Distance Correlation (> 0.95) (monotone vs non-linearity)
cor_contrast11 <- (abs(cor_spearman_mat) < 0.05) & (abs(cor_dist_mat) > 0.95)
cor_contrast_ind11 <- which(cor_contrast11, arr.ind = T)
nrow(cor_contrast_ind11)
## [1] 10
2-11-2. Visualization of Low Spearman (< 0.05) and High Distance Correlation (> 0.95) (monotone vs non-linearity)
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind11)){
index1 <- cor_contrast_ind11[i, 1]; index2 <- cor_contrast_ind11[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Spearman of ", round(cor_spearman_mat[index1, index2], 3)),
"\n",
paste0("Dist. Cor of ", round(cor_dist_mat[index1, index2], 3))))
}

2-12-1. High Spearman (> 0.60) and Low Distance Correlation (< 0.35) (monotone vs non-linearity)
cor_contrast12 <- (abs(cor_spearman_mat) > 0.6) & (abs(cor_dist_mat) < 0.35)
cor_contrast_ind12 <- which(cor_contrast12, arr.ind = T)
nrow(cor_contrast_ind12)
## [1] 6
2-12-2. Visualization of High Spearman (> 0.60) and Low Distance Correlation (< 0.35) (monotone vs non-linearity)
par(mfrow = c(2, 3))
for (i in 1:nrow(cor_contrast_ind12)){
index1 <- cor_contrast_ind12[i, 1]; index2 <- cor_contrast_ind12[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Spearman of ", round(cor_spearman_mat[index1, index2], 3)),
"\n",
paste0("Dist. Cor of ", round(cor_dist_mat[index1, index2], 3))))
}

2-13-1. Low Kendall (< 0.03) and High Distance Correlation (> 0.95) (monotone vs non-linearity)
cor_contrast13 <- (abs(cor_kendall_mat) < 0.03) & (abs(cor_dist_mat) > 0.95)
cor_contrast_ind13 <- which(cor_contrast13, arr.ind = T)
nrow(cor_contrast_ind13)
## [1] 5
2-13-2. Visualization of Low Kendall (< 0.03) and High Distance Correlation (> 0.95) (monotone vs non-linearity)
par(mfrow = c(2, 3))
for (i in 1:nrow(cor_contrast_ind13)){
index1 <- cor_contrast_ind13[i, 1]; index2 <- cor_contrast_ind13[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Kendall of ", round(cor_kendall_mat[index1, index2], 3)),
"\n",
paste0("Dist. Cor of ", round(cor_dist_mat[index1, index2], 3))))
}

2-14-1. High Kendall (> 0.50) and Low Distance Correlation (< 0.50) (monotone vs non-linearity)
cor_contrast14 <- (abs(cor_kendall_mat) > 0.5) & (abs(cor_dist_mat) < 0.5)
cor_contrast_ind14 <- which(cor_contrast14, arr.ind = T)
nrow(cor_contrast_ind14)
## [1] 46
2-14-2. Visualization of High Kendall (> 0.50) and Low Distance Correlation (< 0.50) (monotone vs non-linearity)
par(mfrow = c(2, 3))
for (i in 1:10){
index1 <- cor_contrast_ind14[i, 1]; index2 <- cor_contrast_ind14[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Kendall of ", round(cor_kendall_mat[index1, index2], 3)),
"\n",
paste0("Dist. Cor of ", round(cor_dist_mat[index1, index2], 3))))
}


2-15-1. Low Distance Correlation (< 0.50) and High Hoeffiding’s D (> 0.50) (non-linearity vs monotone)
cor_contrast15 <- (abs(cor_dist_mat) < 0.5) & (abs(cor_hoeffd_mat) > 0.5)
cor_contrast_ind15 <- which(cor_contrast15, arr.ind = T)
nrow(cor_contrast_ind15)
## [1] 0
2-16-1. High Distance Correlation (> 0.90) and Low Hoeffiding’s D (< 0.10) (non-linearity vs monotone)
cor_contrast16 <- (abs(cor_dist_mat) > 0.90) & (abs(cor_hoeffd_mat) < 0.10)
cor_contrast_ind16 <- which(cor_contrast16, arr.ind = T)
nrow(cor_contrast_ind16)
## [1] 1347
2-16-2. Visualization of High Distance Correlation (> 0.90) and Low Hoeffiding’s D (< 0.10) (non-linearity vs monotone)
par(mfrow = c(2, 5))
for (i in 1:10){
index1 <- cor_contrast_ind16[i, 1]; index2 <- cor_contrast_ind16[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Dist. Cor of ", round(cor_dist_mat[index1, index2], 3)),
"\n",
paste0("Hoeffiding's D of ", round(cor_hoeffd_mat[index1, index2], 3))))
}

2-17-1. Low Distance Correlation (< 0.50) and High XI (> 0.50) (non-linearity vs non-linearity)
cor_contrast17 <- (abs(cor_dist_mat) < 0.5) & (abs(cor_XI_mat) > 0.5)
cor_contrast_ind17 <- which(cor_contrast17, arr.ind = T)
nrow(cor_contrast_ind17)
## [1] 0
2-18-1. High Distance Correlation (> 0.90) and Low XI (< 0.10) (non-linearity vs non-linearity)
cor_contrast18 <- (abs(cor_dist_mat) > 0.9) & (abs(cor_XI_mat) < 0.1)
cor_contrast_ind18 <- which(cor_contrast18, arr.ind = T)
nrow(cor_contrast_ind18)
## [1] 651
2-18-2. Visualization of High Distance Correlation (> 0.90) and Low XI (< 0.10) (non-linearity vs non-linearity)
par(mfrow = c(2, 5))
for (i in 1:10){
index1 <- cor_contrast_ind18[i, 1]; index2 <- cor_contrast_ind18[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Dist. Cor of ", round(cor_dist_mat[index1, index2], 3)),
"\n",
paste0("XI of ", round(cor_XI_mat[index1, index2], 3))))
}

2-19-1. Low Distance Correlation (< 0.10) and High Blomqvist’s Beta (> 0.90) (non-linearity vs non-linearity)
cor_contrast19 <- (abs(cor_dist_mat) < 0.1) & (abs(cor_blomqvist_mat) > 0.9)
cor_contrast_ind19 <- which(cor_contrast19, arr.ind = T)
nrow(cor_contrast_ind19)
## [1] 21
2-19-2. Visualization of Low Distance Correlation (< 0.10) and High Blomqvist’s Beta (> 0.90) (non-linearity vs non-linearity)
par(mfrow = c(2, 5))
for (i in 1:10){
index1 <- cor_contrast_ind19[i, 1]; index2 <- cor_contrast_ind19[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Dist. Cor of ", round(cor_dist_mat[index1, index2], 3)),
"\n",
paste0("Blomqvist's Beta of ", round(cor_blomqvist_mat[index1, index2], 3))))
}

2-20-1. High Distance Correlation (> 0.90) and Low Blomqvist’s Beta (< 0.10) (non-linearity vs non-linearity)
cor_contrast20 <- (abs(cor_dist_mat) > 0.9) & (abs(cor_blomqvist_mat) < 0.1)
cor_contrast_ind20 <- which(cor_contrast20, arr.ind = T)
nrow(cor_contrast_ind20)
## [1] 286
2-20-2. Visualization of High Distance Correlation (> 0.90) and Low Blomqvist’s Beta (< 0.10) (non-linearity vs non-linearity)
par(mfrow = c(2, 5))
for (i in 1:10){
index1 <- cor_contrast_ind20[i, 1]; index2 <- cor_contrast_ind20[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Dist. Cor of ", round(cor_dist_mat[index1, index2], 3)),
"\n",
paste0("Blomqvist's Beta of ", round(cor_blomqvist_mat[index1, index2], 3))))
}

3. Explore dense plots
3-1. Visualize dense plots
dense_ind <- t(matrix(c(1, 210, 1, 333, 2, 415, 3, 4, 3, 5, 4, 5,
15, 47, 15, 101, 15, 173, 15, 358),
nrow = 2))
cluster_ind <- dense_ind[c(1,2,4,7,8,9,10),]
par(mfrow = c(2, 3))
for (i in 1:nrow(dense_ind)){
index1 <- dense_ind[i, 1]; index2 <- dense_ind[i, 2];
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"))
}


3-2. Visualize with alpha parameter (transparency)
par(mfrow = c(2, 3))
for (i in 1:nrow(dense_ind)){
index1 <- dense_ind[i, 1]; index2 <- dense_ind[i, 2];
plot(sub_dat[,index1], sub_dat[,index2], col = scales::alpha(sub_cluster_labels, 0.2), asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"))
}


3-3. Visualize with contour plots (density)
#' Plotting density
#'
#' @param mat matrix
#' @param grid_spacing numeric vector
#' @param n integer for \code{stats::kde}
#' @param max_num integer
#' @param density_colors color vector
#' @param point_color color
#' @param contour_color color
#' @param grid_color color
#' @param pch integer
#' @param contour_lwd numeric
#' @param grid_lty integer
#' @param grid_lwd numeric
#' @param ... additional graphical parameters
#'
#' @return nothing
#' @export
plot_density <- function(mat, grid_spacing,
xlim,
ylim,
n = 100,
max_num = 20000,
density_colors = grDevices::heat.colors(100, alpha = 0.8),
point_color = grDevices::rgb(0.5, 0.5, 0.5, 0.8),
contour_color = grDevices::rgb(1,1,1,0.5),
grid_color = "gray",
xaxt = "n",
yaxt = "n",
axes = F,
xlab = "",
ylab = "",
pch = 16,
contour_lwd = 2,
grid_lty = 2,
grid_lwd = 0.5,
...){
stopifnot(ncol(mat) == 2)
mat2 <- rbind(mat,
c(xlim[1], ylim[1]),
c(xlim[1], ylim[2]),
c(xlim[2], ylim[1]),
c(xlim[2], ylim[2]))
f1 <- MASS::kde2d(mat2[,1], mat2[,2], n = 100)
graphics::image(f1,
col = density_colors,
xlim = xlim,
ylim = ylim,
...)
for(i in grid_spacing){
graphics::lines(rep(i,2), c(-2,2)*max(abs(grid_spacing)),
lty = grid_lty,
lwd = grid_lwd,
col = grid_color)
graphics::lines(c(-2,2)*max(abs(grid_spacing)), rep(i,2),
lty = grid_lty,
lwd = grid_lwd,
col = grid_color)
}
if(nrow(mat) > max_num) {
idx <- sample(1:nrow(mat), size = max_num)
} else {
idx <- 1:nrow(mat)
}
graphics::points(mat[idx,1], mat[idx,2],
col = point_color,
pch = pch)
graphics::contour(f1, add = T,
drawlabels = F,
col = contour_color,
lwd = contour_lwd)
invisible()
}
par(mfrow = c(1, 2))
for (i in 1:nrow(dense_ind)){
index1 <- dense_ind[i, 1]; index2 <- dense_ind[i, 2];
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"))
xylim <- par("usr")
x <- sub_dat[,index1]; y <- sub_dat[,index2];
xmin <- min(x); xmax <- max(x); ymin <- min(y); ymax <- max(y);
total_min <- min(xmin, ymin); total_max <- max(xmax, ymax);
plot_density(cbind(x, y),
grid_spacing = seq(total_min, total_max, by=((total_max - total_min) / 10)),
xlim = c(xylim[1], xylim[2]), ylim = c(xylim[3], xylim[4]),
xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"))
}










par(mfrow = c(1,2))
for (i in 1:nrow(cluster_ind)){
index1 <- cluster_ind[i, 1]; index2 <- cluster_ind[i, 2];
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"))
x <- sub_dat[,index1]; y <- sub_dat[,index2];
xmin <- min(x); xmax <- max(x); ymin <- min(y); ymax <- max(y);
total_min <- min(xmin, ymin); total_max <- max(xmax, ymax);
plot_density(cbind(x, y),
grid_spacing = seq(total_min, total_max, by = 10),
xlim = c(-20, 60), ylim = c(-50, 50),
xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"))
}







4. Define a function to exclude repeated indices
contrast_helper <- function(contrast_ind, threshold){
to_track <- data.frame()
for (i in 1:nrow(contrast_ind)){
ind1 <- contrast_ind[i, 1]; ind2 <- contrast_ind[i, 2];
if (i == 1){ # first element
to_track <- data.frame(row.names = c(ind1, ind2), val = c(1, 1))
ans <- matrix(contrast_ind[i, ], nrow = 1)
} else {
if (nrow(ans) == 10) { # want to extract 10 pairs
break
} else {
row_names <- row.names(to_track)
ind1_str <- toString(ind1); ind2_str <- toString(ind2);
if (ind1_str %in% row_names){
first_bool <- to_track[ind1_str, ] < threshold
to_track[ind1_str, ] <- to_track[ind1_str, ] + 1
} else {
to_track[ind1_str, ] <- 1
first_bool <- TRUE
}
if (ind2_str %in% row_names){
second_bool <- to_track[ind2_str, ] < threshold
to_track[ind2_str, ] <- to_track[ind2_str, ] + 1
} else {
to_track[ind2_str, ] <- 1
second_bool <- TRUE
}
if (first_bool & second_bool){
ans <- rbind(ans, contrast_ind[i,])
}
}
}
}
return (ans)
}
4-1-1. Low Pearson (< 0.40) and High Spearman (> 0.60) (linearity vs monotone)
cor_contrast1 <- (abs(cor_pearson_mat) < 0.4) & (abs(cor_spearman_mat) > 0.6)
cor_contrast_ind1 <- which(cor_contrast1, arr.ind = T)
cor_contrast_ind1 <- contrast_helper(cor_contrast_ind1, 3)
nrow(cor_contrast_ind1)
## [1] 3
4-1-2. Visualization of Low Pearson (< 0.40) and High Spearman (> 0.60) (linearity vs monotone)
par(mfrow = c(2, 2))
for (i in 1:nrow(cor_contrast_ind1)){
index1 <- cor_contrast_ind1[i, 1]; index2 <- cor_contrast_ind1[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("Spearman of ", round(cor_spearman_mat[index1, index2], 3))))
}

4-2-1. High Pearson (> 0.89) and Low Spearman (< 0.15) (linearity vs monotone)
cor_contrast2 <- (abs(cor_pearson_mat) > 0.80) & (abs(cor_spearman_mat) < 0.15)
cor_contrast_ind2 <- which(cor_contrast2, arr.ind = T)
cor_contrast_ind2 <- contrast_helper(cor_contrast_ind2, 3)
nrow(cor_contrast_ind2)
## [1] 6
4-2-2. Visualization of High Pearson (> 0.89) and Low Spearman (< 0.15) (linearity vs monotone)
par(mfrow = c(2, 3))
for (i in 1:nrow(cor_contrast_ind2)){
index1 <- cor_contrast_ind2[i, 1]; index2 <- cor_contrast_ind2[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("Spearman of ", round(cor_spearman_mat[index1, index2], 3))))
}

4-4-1. Low Pearson (< 0.50) and High Kendall (> 0.50) (linearity vs monotone)
cor_contrast3 <- (abs(cor_pearson_mat) < 0.5) & (abs(cor_kendall_mat) > 0.5)
cor_contrast_ind3 <- which(cor_contrast3, arr.ind = T)
cor_contrast_ind3 <- contrast_helper(cor_contrast_ind3, 3)
nrow(cor_contrast_ind3)
## [1] 8
4-4-2. Visualization of Low Pearson (< 0.50) and High Kendall (> 0.50) (linearity vs monotone)
par(mfrow = c(2, 4))
for (i in 1:nrow(cor_contrast_ind3)){
index1 <- cor_contrast_ind3[i, 1]; index2 <- cor_contrast_ind3[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("Kendall of ", round(cor_kendall_mat[index1, index2], 3))))
}

4-4-1. High Pearson (> 0.80) and Low Kendall (< 0.20) (linearity vs monotone)
cor_contrast4 <- (abs(cor_pearson_mat) > 0.80) & (abs(cor_kendall_mat) < 0.20)
cor_contrast_ind4 <- which(cor_contrast4, arr.ind = T)
cor_contrast_ind4 <- contrast_helper(cor_contrast_ind4, 3)
nrow(cor_contrast_ind4)
## [1] 10
4-4-2. Visualization of High Pearson (> 0.80) and Low Kendall (< 0.20) (linearity vs monotone)
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind4)){
index1 <- cor_contrast_ind4[i, 1]; index2 <- cor_contrast_ind4[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("Kendall of ", round(cor_kendall_mat[index1, index2], 3))))
}

4-5-1. Low Pearson (< 0.50) and High Hoeffding’s D (> 0.50) (linearity vs monotone)
cor_contrast5 <- (abs(cor_pearson_mat) < 0.5) & (abs(cor_hoeffd_mat) > 0.5)
cor_contrast_ind5 <- which(cor_contrast5, arr.ind = T)
nrow(cor_contrast_ind5)
## [1] 0
4-6-1. High Pearson (> 0.90) and Low Hoeffding’s D (< 0.1) (linearity vs monotone)
cor_contrast6 <- (abs(cor_pearson_mat) > 0.9) & (abs(cor_hoeffd_mat) < 0.1)
cor_contrast_ind6 <- which(cor_contrast6, arr.ind = T)
cor_contrast_ind6 <- contrast_helper(cor_contrast_ind6, 3)
nrow(cor_contrast_ind6)
## [1] 10
4-6-2. Visualization of High Pearson (> 0.90) and Low Hoeffding’s D (< 0.1) (linearity vs monotone)
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind6)){
index1 <- cor_contrast_ind6[i, 1]; index2 <- cor_contrast_ind6[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("Hoeffding's D of ", round(cor_hoeffd_mat[index1, index2], 3))))
}

4-7-1. Low Pearson (< 0.15) and high Blomqvist’s beta (> 0.9) (linearity vs monotone)
cor_contrast7 <- (abs(cor_pearson_mat) < 0.15) & (abs(cor_blomqvist_mat) > 0.9)
cor_contrast_ind7 <- which(cor_contrast7, arr.ind = T)
cor_contrast_ind7 <- contrast_helper(cor_contrast_ind7, 3)
nrow(cor_contrast_ind7)
## [1] 10
4-7-2. Visualization of Low Pearson (< 0.15) and high Blomqvist’s beta (> 0.9) (linearity vs monotone)
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind7)){
index1 <- cor_contrast_ind7[i, 1]; index2 <- cor_contrast_ind7[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("Beta of ", round(cor_blomqvist_mat[index1, index2], 3))))
}

4-8-1. High Pearson (> 0.85) and Low Blomqvist’s beta (< 0.15) (linearity vs monotone)
cor_contrast8 <- (abs(cor_pearson_mat) > 0.85) & (abs(cor_blomqvist_mat) < 0.15)
cor_contrast_ind8 <- which(cor_contrast8, arr.ind = T)
cor_contrast_ind8 <- contrast_helper(cor_contrast_ind8, 3)
nrow(cor_contrast_ind8)
## [1] 10
4-8-2. Visualization of High Pearson (> 0.85) and Low Blomqvist’s beta (< 0.15) (linearity vs monotone)
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind8)){
index1 <- cor_contrast_ind8[i, 1]; index2 <- cor_contrast_ind8[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("Beta of ", round(cor_blomqvist_mat[index1, index2], 3))))
}

4-9-1. Low Pearson (< 0.50) and High XI (> 0.50) (linearity vs non-linearity)
cor_contrast9 <- (abs(cor_pearson_mat) < 0.5) & (abs(cor_XI_mat) > 0.5)
cor_contrast_ind9 <- which(cor_contrast9, arr.ind = T)
nrow(cor_contrast_ind9)
## [1] 0
4-10-1. High Pearson (> 0.85) and Low XI (< 0.15) (linearity vs non-linearity)
cor_contrast10 <- (abs(cor_pearson_mat) > 0.85) & (abs(cor_XI_mat) < 0.15)
cor_contrast_ind10 <- which(cor_contrast10, arr.ind = T)
cor_contrast_ind10 <- contrast_helper(cor_contrast_ind10, 3)
nrow(cor_contrast_ind10)
## [1] 10
4-10-2. Visualization of High Pearson (> 0.85) and Low XI (< 0.15) (linearity vs non-linearity)
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind10)){
index1 <- cor_contrast_ind10[i, 1]; index2 <- cor_contrast_ind10[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("XI of ", round(cor_XI_mat[index1, index2], 3))))
}

4-11-1. Low Spearman (< 0.10) and High Distance Correlation (> 0.90) (monotone vs non-linearity)
cor_contrast11 <- (abs(cor_spearman_mat) < 0.10) & (abs(cor_dist_mat) > 0.90)
cor_contrast_ind11 <- which(cor_contrast11, arr.ind = T)
cor_contrast_ind11 <- contrast_helper(cor_contrast_ind11, 3)
nrow(cor_contrast_ind11)
## [1] 10
4-11-2. Visualization of Low Spearman (< 0.10) and High Distance Correlation (> 0.90) (monotone vs non-linearity)
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind11)){
index1 <- cor_contrast_ind11[i, 1]; index2 <- cor_contrast_ind11[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Spearman of ", round(cor_spearman_mat[index1, index2], 3)),
"\n",
paste0("Dist. Cor of ", round(cor_dist_mat[index1, index2], 3))))
}

4-12-1. High Spearman (> 0.60) and Low Distance Correlation (< 0.4) (monotone vs non-linearity)
cor_contrast12 <- (abs(cor_spearman_mat) > 0.6) & (abs(cor_dist_mat) < 0.4)
cor_contrast_ind12 <- which(cor_contrast12, arr.ind = T)
cor_contrast_ind12 <- contrast_helper(cor_contrast_ind12, 3)
nrow(cor_contrast_ind12)
## [1] 9
4-12-2. Visualization of High Spearman (> 0.60) and Low Distance Correlation (< 0.4) (monotone vs non-linearity)
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind12)){
index1 <- cor_contrast_ind12[i, 1]; index2 <- cor_contrast_ind12[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Spearman of ", round(cor_spearman_mat[index1, index2], 3)),
"\n",
paste0("Dist. Cor of ", round(cor_dist_mat[index1, index2], 3))))
}

4-13-1. Low Kendall (< 0.10) and High Distance Correlation (> 0.90) (monotone vs non-linearity)
cor_contrast13 <- (abs(cor_kendall_mat) < 0.10) & (abs(cor_dist_mat) > 0.90)
cor_contrast_ind13 <- which(cor_contrast13, arr.ind = T)
cor_contrast_ind13 <- contrast_helper(cor_contrast_ind13, 3)
nrow(cor_contrast_ind13)
## [1] 10
4-13-2. Visualization of Low Kendall (< 0.10) and High Distance Correlation (> 0.90) (monotone vs non-linearity)
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind13)){
index1 <- cor_contrast_ind13[i, 1]; index2 <- cor_contrast_ind13[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Kendall of ", round(cor_kendall_mat[index1, index2], 3)),
"\n",
paste0("Dist. Cor of ", round(cor_dist_mat[index1, index2], 3))))
}

4-14-1. High Spearman (> 0.60) and Low Distance Correlation (< 0.4) (monotone vs non-linearity)
cor_contrast14 <- (abs(cor_spearman_mat) > 0.6) & (abs(cor_dist_mat) < 0.4)
cor_contrast_ind14 <- which(cor_contrast14, arr.ind = T)
cor_contrast_ind14 <- contrast_helper(cor_contrast_ind14, 3)
nrow(cor_contrast_ind14)
## [1] 9
4-14-2. Visualization of High Spearman (> 0.60) and Low Distance Correlation (< 0.4) (monotone vs non-linearity)
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind14)){
index1 <- cor_contrast_ind14[i, 1]; index2 <- cor_contrast_ind14[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Spearman of ", round(cor_spearman_mat[index1, index2], 3)),
"\n",
paste0("Dist. Cor of ", round(cor_dist_mat[index1, index2], 3))))
}

4-15-1. Low Kendall (< 0.05) and High Distance Correlation (> 0.90) (monotone vs non-linearity)
cor_contrast15 <- (abs(cor_kendall_mat) < 0.05) & (abs(cor_dist_mat) > 0.90)
cor_contrast_ind15 <- which(cor_contrast15, arr.ind = T)
cor_contrast_ind15 <- contrast_helper(cor_contrast_ind15, 3)
nrow(cor_contrast_ind15)
## [1] 6
4-15-2. Visualization of Low Kendall (< 0.05) and High Distance Correlation (> 0.90) (monotone vs non-linearity)
par(mfrow = c(2, 3))
for (i in 1:nrow(cor_contrast_ind15)){
index1 <- cor_contrast_ind15[i, 1]; index2 <- cor_contrast_ind15[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Kendall of ", round(cor_kendall_mat[index1, index2], 3)),
"\n",
paste0("Dist. Cor of ", round(cor_dist_mat[index1, index2], 3))))
}

4-16-1. High Kendall (> 0.50) and Low Distance Correlation (< 0.50) (monotone vs non-linearity)
cor_contrast16 <- (abs(cor_kendall_mat) > 0.5) & (abs(cor_dist_mat) < 0.5)
cor_contrast_ind16 <- which(cor_contrast16, arr.ind = T)
cor_contrast_ind16 <- contrast_helper(cor_contrast_ind16, 3)
nrow(cor_contrast_ind16)
## [1] 10
4-16-2. Visualization of High Kendall (> 0.50) and Low Distance Correlation (< 0.50) (monotone vs non-linearity)
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind16)){
index1 <- cor_contrast_ind16[i, 1]; index2 <- cor_contrast_ind16[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Kendall of ", round(cor_kendall_mat[index1, index2], 3)),
"\n",
paste0("Dist. Cor of ", round(cor_dist_mat[index1, index2], 3))))
}

4-17-1. Low Distance Correlation (< 0.50) and High Hoeffiding’s D (> 0.50) (non-linearity vs monotone)
cor_contrast17 <- (abs(cor_dist_mat) < 0.5) & (abs(cor_hoeffd_mat) > 0.5)
cor_contrast_ind17 <- which(cor_contrast17, arr.ind = T)
nrow(cor_contrast_ind17)
## [1] 0
4-18-1. High Distance Correlation (> 0.90) and Low Hoeffiding’s D (< 0.10) (non-linearity vs monotone)
cor_contrast18 <- (abs(cor_dist_mat) > 0.90) & (abs(cor_hoeffd_mat) < 0.10)
cor_contrast_ind18 <- which(cor_contrast18, arr.ind = T)
cor_contrast_ind18 <- contrast_helper(cor_contrast_ind18, 3)
nrow(cor_contrast_ind18)
## [1] 10
4-18-2. Visualization of High Distance Correlation (> 0.90) and Low Hoeffiding’s D (< 0.10) (non-linearity vs monotone)
par(mfrow = c(2, 5))
for (i in 1:10){
index1 <- cor_contrast_ind18[i, 1]; index2 <- cor_contrast_ind18[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 18, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Dist. Cor of ", round(cor_dist_mat[index1, index2], 3)),
"\n",
paste0("Hoeffiding's D of ", round(cor_hoeffd_mat[index1, index2], 3))))
}

4-19-1. Low Distance Correlation (< 0.50) and High XI (> 0.50) (non-linearity vs non-linearity)
cor_contrast19 <- (abs(cor_dist_mat) < 0.5) & (abs(cor_XI_mat) > 0.5)
cor_contrast_ind19 <- which(cor_contrast19, arr.ind = T)
nrow(cor_contrast_ind19)
## [1] 0
4-20-1. High Distance Correlation (> 0.90) and Low XI (< 0.10) (non-linearity vs non-linearity)
cor_contrast20 <- (abs(cor_dist_mat) > 0.9) & (abs(cor_XI_mat) < 0.1)
cor_contrast_ind20 <- which(cor_contrast20, arr.ind = T)
cor_contrast_ind20 <- contrast_helper(cor_contrast_ind20, 3)
nrow(cor_contrast_ind20)
## [1] 10
4-20-2. Visualization of High Distance Correlation (> 0.90) and Low XI (< 0.10) (non-linearity vs non-linearity)
par(mfrow = c(2, 5))
for (i in 1:10){
index1 <- cor_contrast_ind20[i, 1]; index2 <- cor_contrast_ind20[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Dist. Cor of ", round(cor_dist_mat[index1, index2], 3)),
"\n",
paste0("XI of ", round(cor_XI_mat[index1, index2], 3))))
}

4-21-1. Low Distance Correlation (< 0.10) and High Blomqvist’s Beta (> 0.90) (non-linearity vs non-linearity)
cor_contrast21 <- (abs(cor_dist_mat) < 0.1) & (abs(cor_blomqvist_mat) > 0.9)
cor_contrast_ind21 <- which(cor_contrast21, arr.ind = T)
cor_contrast_ind21 <- contrast_helper(cor_contrast_ind21, 3)
nrow(cor_contrast_ind21)
## [1] 10
4-21-2. Visualization of Low Distance Correlation (< 0.10) and High Blomqvist’s Beta (> 0.90) (non-linearity vs non-linearity)
par(mfrow = c(2, 5))
for (i in 1:10){
index1 <- cor_contrast_ind21[i, 1]; index2 <- cor_contrast_ind21[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Dist. Cor of ", round(cor_dist_mat[index1, index2], 3)),
"\n",
paste0("Blomqvist's Beta of ", round(cor_blomqvist_mat[index1, index2], 3))))
}

4-22-1. High Distance Correlation (> 0.90) and Low Blomqvist’s Beta (< 0.10) (non-linearity vs non-linearity)
cor_contrast22 <- (abs(cor_dist_mat) > 0.9) & (abs(cor_blomqvist_mat) < 0.1)
cor_contrast_ind22 <- which(cor_contrast22, arr.ind = T)
cor_contrast_ind22 <- contrast_helper(cor_contrast_ind22, 3)
nrow(cor_contrast_ind22)
## [1] 10
4-22-2. Visualization of High Distance Correlation (> 0.90) and Low Blomqvist’s Beta (< 0.10) (non-linearity vs non-linearity)
par(mfrow = c(2, 5))
for (i in 1:10){
index1 <- cor_contrast_ind22[i, 1]; index2 <- cor_contrast_ind22[i, 2]
plot(sub_dat[,index1], sub_dat[,index2], col = sub_cluster_labels, asp = T,
pch = 16, xlab = paste0(colnames(sub_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(sub_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Dist. Cor of ", round(cor_dist_mat[index1, index2], 3)),
"\n",
paste0("Blomqvist's Beta of ", round(cor_blomqvist_mat[index1, index2], 3))))
}
